package Model

import "time"

type Employee struct {
	itsEmpid          int
	itsName           string
	itsAddress        string
	itsClassification PaymentClassification
	itsSchedule       PaymentSchedule
	itsPaymentMethod  PaymentMethod
	itsAffiliation    Affiliation
}

func (e *Employee) NewEmployee(itsEmpid int, itsName string, itsAddress string) Employee {
	e.itsEmpid = itsEmpid
	e.itsName = itsName
	e.itsAddress = itsAddress
}

func (e *Employee) SetEmpid(empid int) {
	e.itsEmpid = empid
}

func (e *Employee) SetSchedule(ps PaymentSchedule) {
	e.itsSchedule = ps
}

func (e *Employee) SetMethod(pm PaymentMethod) {
	e.itsPaymentMethod = pm
}

func (e *Employee) SetClassification(pc PaymentClassification) {
	e.itsClassification = pc
}

func (e *Employee) SetName(name string) {
	e.itsName = name
}

func (e *Employee) SetAddress(address string) {
	e.itsAddress = address
}

func (e *Employee) SetAffiliation(af Affiliation) {
	e.itsAffiliation = af
}

func (e *Employee) GetSchedule() PaymentSchedule {
	return e.itsSchedule
}

func (e *Employee) GetClassification() PaymentClassification {
	return e.itsClassification
}

func (e *Employee) GetName() string {
	return e.itsName
}

func (e *Employee) GetEmpid() int {
	return e.itsEmpid
}

func (e *Employee) GetAddress() string {
	return e.itsAddress
}

func (e *Employee) GetMethod() PaymentMethod {
	return e.itsPaymentMethod
}

func (e *Employee) GetAffiliation() Affiliation {
	return e.itsAffiliation
}

func (e *Employee) GetPayPeriodStartDate(payPeriodEndDate time.Time) time.Time {
	return e.itsSchedule.GetPayPeriodStartDate(payPeriodEndDate)
}

func (e *Employee) IsPayDate(date time.Time) bool {
	return e.itsSchedule.IsPayData(date)
}

func (e *Employee) Payday(pc Paycheck) {
	grossPay := e.itsClassification.CalculatePay(pc)
	deductions := e.itsAffiliation.CalculateDeductions(pc)
	netPay := grossPay - deductions
	pc.SetGrossPay(grossPay)
	pc.SetNetPay(netPay)
	pc.SetDeductions(deductions)
	e.itsPaymentMethod.Pay(pc)
}
